



def to_original_code(number, bit_length):
    if number >= 0:
        # 正数的原码就是其二进制表示
        binary_representation = bin(number)[2:]
        return binary_representation.zfill(bit_length)  # 补零以满足位数
    else:
        # 负数的原码是将其绝对值的二进制表示的符号位取反
        abs_value = abs(number)
        binary_representation = bin(abs_value)[2:]
        complemented_binary = ''.join('0' if bit == '1' else '1' for bit in binary_representation)
        return complemented_binary.zfill(bit_length)  # 补零以满足位数

# 示例
number = 9/16
bit_length = 8  # 假设使用8位表示
original_code = to_original_code(number, bit_length)
print(original_code)
